import React from 'react'
import {StarsWrap} from './style'
class Star extends React.Component {
    render() {
        // 获取 star 数量，并取余5（最多5个star）
        let star = this.props.star || 0
        if (star > 5) {
            star = star % 5
        }
        return (
            <StarsWrap>
                {[1, 2, 3, 4, 5].map((item, index) => {
                    const lightClass = star >= item ? ' light' : ''
                    return <i key={index} className={'iconfont' + lightClass}> &#xe642;</i>
                })}
            </StarsWrap>
        )
    }
}
export default Star